//
//  LBProfileNoteView.m
//  app
//
//  Created by 杨庆人 on 16/12/26.
//  Copyright © 2016年 广东联结电子商务有限公司. All rights reserved.
//

#import "LBProfileNoteView.h"
#import <LBCategory/LBCategory.h>
#import <Masonry/Masonry.h>

@interface LBProfileNoteView ()

@property (nonatomic,copy)NSString * title;
@property (nonatomic,copy)NSString * details;
@property (nonatomic,assign)NSInteger limit;
@end
@implementation LBProfileNoteView

- (instancetype)initWithTitle:(NSString *)title details:(NSString *)details limit:(NSInteger)limit {
    if (self = [super init]) {
        _title = title;
        _details = details;
        _limit = limit;
        [self setProfileNoteView];
    }
    return self;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:12];
        _titleLabel.textColor = [UIColor colorWithR:134 G:134 B:134 A:1];
        _titleLabel.text = _title;
    }
    return _titleLabel;
}
- (LBBasicInputTextView *)textView {
    if (!_textView) {
        _textView = [[LBBasicInputTextView alloc] initWithPlaceholder:_details limit:_limit];
    }
    return _textView;
}

- (NSString *)note {
    return self.textView.inputTextView.text;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    __weak typeof(self)weakSelf = self;
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(weakSelf);
        make.height.mas_equalTo(17);
    }];
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.mas_equalTo(weakSelf);
        make.top.mas_equalTo(weakSelf.titleLabel.mas_bottom).offset(9);
    }];

}
- (void)setProfileNoteView {
    [self addSubview:self.titleLabel];
    [self addSubview:self.textView];
}
@end
